# What's here:

### linux-rockchip-rk3588-bin

[AUR package](https://aur.archlinux.org/packages/linux-rockchip-rk3588-bin)
with pre-build armbian kernel.
[Modified](https://notabug.org/not_tom/orange-pi5-packages/src/master/linux-rockchip-rk3588-bin/PKGBUILD#L105)
to allow DKMS to work.

### orange-pi5-board-package

Script and configs adapted from armbian. Includes script to generate uBoot image
and boot.scr

### mesa-panfork-git

Clone of [AUR package](https://aur.archlinux.org/packages/mesa-panfork-git) with
disabled gallium-nine and [unrelated drivers](https://notabug.org/not_tom/orange-pi5-packages/src/master/mesa-panfork-git/PKGBUILD#L55).

### 8188eu-dkms-git

DKMS module for random USB wifi dongle I had around.
[Modified](https://notabug.org/not_tom/orange-pi5-packages/src/master/8188eu-dkms-git/build.patch)
so it builds.


# Howto

- Download [Armtix tarball](https://armtix.artixlinux.org/images/) of your favorite flavour
- Install on PC, not on Orange PI, either:
    - qemu-user-static and qemu-user-static-binfmt
    - or qemu-user and qemu-user-binfmt
- Grab reasonably big SD card (4GB seems to be minimum)
- Partition SD card and format it as such:

```
partition table type: GPT
/dev/sdX1: ext4, type=linux extended boot, name=bootfs, start=32768, 512MB
/dev/sdX2: ext4, type=linux filesystem, rest of card
```

(notice 1st partition starts at offset 32768)
- install uboot boot loader onto sdcard

```
# wget https://notabug.org/not_tom/orange-pi5-packages/raw/master/uboot-files/{idbloader.img,u-boot.itb}
# dd if=idbloader.img of=/dev/sdX conv=notrunc seek=64
# dd if=u-boot.itb of=/dev/sdX conv=notrunc seek=16384
```

  Make **ABSOLUTELLY** sure you are getting /dev/sdX correct here. You may blow up your system otherwise.
- (you may want to `sync`, eject sdcard and put it back to make sure partitions are still intact after above step)
- mount /dev/sdX2: `mount /dev/sdX2 /tmp/sdcard` (make sure to replace X in sdX2)
- extract tarball `cd /tmp/sdcard && tar xvf <PATH_TO_TARBALL>`
- mount /def/sdX1 as /boot of sdcard: `mount /dev/sdX1 /tmp/sdcard/boot/` (make sure to replace X in sdX1)
- copy resolv.conf to sdcard: `cp -v /etc/resolv.conf /tmp/sdcard/etc`
- mount /dev and /proc:

```
# mount -t devtmpfs none /tmp/sdcard/dev
# mount -t proc none /tmp/sdcard/proc
```

- chroot into 'installation': `chroot /tmp/sdcard/ /usr/bin/bash` (this is what you need qemu-\* packages for)
- remove kernels: `pacman -R linux-aarch64 linux-aarch64-headers linux-aarch64-lts linux-aarch64-lts-headers` (please, make sure you are doing this *in chroot*)
- update everything else, install required packages: `pacman -Syu && pacman -S git fakeroot uboot-tools make gcc flex bison`
- switch to default armtix user (so makepkg can be used): `su -l armtix`
- clone this repository: `git clone https://notabug.org/not_tom/orange-pi5-packages.git && cd orange-pi5-packages`
- build kernel package: `cd linux-rockchip-rk3588-bin && makepkg`
- build board package: `cd ../orange-pi5-board-package/ && makepkg`
- drop back to root account (`exit`) and install built packages:

```
# pacman -U  ~armtix/orange-pi5-packages/orange-pi5-board-package/*.tar.xz ~armtix/orange-pi5-packages/linux-rockchip-rk3588-bin/*.tar.xz
```

- exit chroot (`exit`) and check that /boot on sdcard is populated correctly

```
# ls -la /tmp/sdcard/boot/
-rw-r--r--  1 root root      212 Jan 22 18:52 armtixEnv.txt
-rw-r--r--  1 root root     3249 Jan 22 18:49 boot.scr
lrwxrwxrwx  1 root root        4 Jan 22 18:49 dtb -> dtbs
drwxr-xr-x  3 root root     4096 Jan 22 18:51 dtbs
-rw-------  1 root root  9505049 Jan 22 18:52 initramfs-linux-rockchip-rk3588.img
lrwxrwxrwx  1 root root       29 Jan 22 18:49 Image -> vmlinuz-linux-rockchip-rk3588
lrwxrwxrwx  1 root root       29 Jan 22 18:49 uInitrd -> uInitrd-linux-rockchip-rk3588
-rw-r--r--  1 root root  9505113 Jan 22 18:52 uInitrd-linux-rockchip-rk3588
-rw-r--r--  1 root root 33020416 Jan 22 18:51 vmlinuz-linux-rockchip-rk3588
```

- fix UUID in `armtixEnv.txt` which couldn't be detected in chroot (make sure to replace X in sdX2)

```
# sed -i  's|rootdev=.*|rootdev=UUID='$(lsblk /dev/sdX2 -o uuid | tail -1)'|' /tmp/sdcard/boot/armtixEnv.txt
# cat /tmp/sdcard/boot/armtixEnv.txt | grep rootdev && lsblk /dev/sdX2 -o uuid
```

  (check that above command outputs two UUIDs, both same)

- umount everything and sync to make sure it's safe to remove sdcard

```
# for x in /tmp/sdcard/dev /tmp/sdcard/proc /tmp/sdcard/boot /tmp/sdcard ; do umount $x ; done
# sync
```

- put sdcard into Orange PI 5 and boot from it

